package com.kim.smartring.net.entity;

import org.json.JSONObject;

import android.content.Context;
import android.util.Log;

import com.kim.smartring.db.model.User;
import com.kim.smartring.net.IReceiverListener;

public class UpdateUserInfoEntity extends BaseEntity {

	private static final String TAG = "UpdateUserInfoEntity";

	private String uid;
	private int height;
	private float weight;
	private String address;
	private String deviceId;

	public UpdateUserInfoEntity(Context context,
			IReceiverListener receiverListener) {
		super(context, receiverListener);
	}

	public UpdateUserInfoEntity(Context context, User user,
			IReceiverListener receiverListener) {
		super(context, receiverListener);
		this.uid = user.getUserId();
		this.height = user.getHeight();
		this.weight = user.getWeight();
		this.address = user.getUserAddress();
		this.deviceId = user.getDeviceAddress();
	}

	@Override
	protected void init() {
		this.url = URLConstant.URL_UPDATE_USER_INFO;
	}

	@Override
	public String getSendData() {
		return generateSendData();
	}

	private String generateSendData() {
		JSONObject jsonObject = new JSONObject();
		String sendData = null;
		try {
			jsonObject.put("userId", uid);
			jsonObject.put("height", height);
			jsonObject.put("weight", weight);
			jsonObject.put("address", address);
			jsonObject.put("deviceId", deviceId);
			sendData = jsonObject.toString();
			Log.d(TAG, String.format("update user info send data:$s", sendData));
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			jsonObject = null;
		}
		return sendData;
	}

	/*
	 * { 　　“account”:”账号”, 　　“height”:168, 　　“weight”:76 }
	 */

}
